import type { Component as ComponentType } from '@/components/BasicModalForm/types';
import type { Component } from 'vue';

/**
 * Component list, register here to setting it in the form
 */
import {
  ElDatePicker,
  ElInput,
  ElInputNumber,
  ElUpload,
  ElCascader,
  ElRate,
  ElSwitch,
  ElTreeSelect,
} from 'element-plus';
import ApiSelect from '@/components/BasicModalForm/components/ApiSelect.vue';
import ApiCheckbox from '@/components/BasicModalForm/components/ApiCheckbox.vue';
import ApiRadio from '@/components/BasicModalForm/components/ApiRadio.vue';
import ApiCascader from '@/components/BasicModalForm/components/ApiCascader.vue';
import ApiTreeSelect from '@/components/BasicModalForm/components/ApiTreeSelect.vue';
import FileUpload from '@/components/FileUpload/index.vue';
import ImageUpload from '@/components/ImageUpload/index.vue';
import Select from '@/components/BasicModalForm/components/Select.vue';
import Radio from '@/components/BasicModalForm/components/Radio.vue';
import Checkbox from '@/components/BasicModalForm/components/Checkbox.vue';

const componentMap = new Map<ComponentType, Component>();
// 可自定义扩展组件
componentMap.set('el-input', ElInput);
componentMap.set('el-input-number', ElInputNumber);
componentMap.set('el-date-picker', ElDatePicker);
componentMap.set('el-select', Select);
componentMap.set('Select', Select);
componentMap.set('el-radio', Radio);
componentMap.set('el-checkbox', Checkbox);
componentMap.set('el-upload', ElUpload);
componentMap.set('el-rate', ElRate);

componentMap.set('el-cascader', ElCascader);
componentMap.set('el-switch', ElSwitch);
componentMap.set('el-tree-select', ElTreeSelect);
componentMap.set('ApiSelect', ApiSelect);
componentMap.set('ApiCheckbox', ApiCheckbox);
componentMap.set('ApiRadio', ApiRadio);
componentMap.set('ApiCascader', ApiCascader);
componentMap.set('ApiTreeSelect', ApiTreeSelect);
componentMap.set('ImageUpload', ImageUpload);
componentMap.set('FileUpload', FileUpload);
export function add(compName: ComponentType, component: Component) {
  componentMap.set(compName, component);
}

export function del(compName: ComponentType) {
  componentMap.delete(compName);
}

export { componentMap };
